package com.hthy.futures.ui.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hthy.futures.AppContext;
import com.hthy.futures.R;
import com.hthy.futures.base.BaseFragment;
import com.hthy.futures.bean.ht.BRealTimeQuotePush;
import com.hthy.futures.ui.activity.FundActivity;
import com.hthy.futures.ui.activity.LoginActivity;
import com.hthy.futures.ui.activity.Seach2Activity;
import com.hthy.futures.ui.activity.ShareActivity;
import com.hthy.futures.ui.activity.SlideCotainerActivity;
import com.hthy.futures.utils.TDevice;

import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 侧边栏
 * Author:  Mr.bingley
 * Version:
 * Date:  2017/4/18
 */

public class NavigationFragment extends BaseFragment {
    @Bind(R.id.tv_account)
    TextView tvAccount;
    @Bind(R.id.tv_userName)
    TextView tvUserName;
    @Bind(R.id.tv_version)
    TextView tvVersion;
    @Bind(R.id.drawer_out_share)
    LinearLayout mDrawerOutShare;

    @Override
    protected int getLayoutId() {
        return R.layout.navigator_left_layout;
    }

    @Override
    protected void initWidget(View root) {
        super.initWidget(root);
        tvAccount.setText("用户： " + AppContext.accountName);
        tvUserName.setText("账号：" + AppContext.account);

        tvVersion.setText("版本" + TDevice.getVersionName());

        if (!AppContext.isMarket) {
            mDrawerOutShare.setVisibility(View.GONE);
        }
    }

    @OnClick({R.id.drawer_update_pwd, R.id.drawer_in_money, R.id.drawer_out_money,R.id.drawer_out_share,R.id.drawer_out_fund,R.id.drawer_out_search,R.id.bt_exit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.drawer_update_pwd:
                SlideCotainerActivity.gotoActivity(getActivity(), 1);
                break;
            case R.id.drawer_in_money:
                SlideCotainerActivity.gotoActivity(getActivity(), 2);
                break;
            case R.id.drawer_out_money:
                SlideCotainerActivity.gotoActivity(getActivity(), 3);
                break;
            case R.id.drawer_out_share:
                startActivity(new Intent(getActivity(),ShareActivity.class));
                //   SlideCotainerActivity.gotoActivity(getActivity(), 6);
                break;
            case R.id.drawer_out_fund:
                startActivity(new Intent(getActivity(), FundActivity.class));

                break;
            case R.id.drawer_out_search:
                startActivity(new Intent(getActivity(), Seach2Activity.class));
                break;
            case R.id.bt_exit:
                startActivity(new Intent(getActivity(), LoginActivity.class));
                getActivity().finish();
                break;
        }
    }

    public void setRealTimeQuotePushes(List<BRealTimeQuotePush> realTimeQuotePushes) {

        FundActivity.setRealTimeQuotePushes(realTimeQuotePushes);
    }
}
